#include "DB.h"
#include <iostream>
using namespace std;

//General case; not implemented
template <typename T> struct DbTraits;

//specialize for int
template <>
struct DbTraits<int>
{
	enum { TypeId = DB_INTEGER };
	typedef db_integer DbNativeType;
	static void Init(DbNativeType& from)
	{
		from = 1000;
	}
	static void Convert(DbNativeType from, int& to)
	{
		to = static_cast<int>(from);
		cout << "DbTraits<int>::Convert" << endl;
	}
};

//specialize for double
template <>
struct DbTraits<double>
{
	enum { TypeID = DB_CURRENCY };
	typedef db_currency DbNativeType;
	static void Init(DbNativeType& from)
	{
		from.integral_part = 1000;
		from.integral_part = 11;
	}
	static void Convert(const DbNativeType& from, double& to)
	{
		to = from.integral_part + from.fractionary_part / 100. ;
		cout << "DbTraits<double>::Convert" << endl;
	}
};